package com.pj.wisdomlogistics.mvp.presenter;


import com.pj.wisdomlogistics.entity.RepairQuestions;
import com.pj.wisdomlogistics.mvp.contract.RepairContract;
import com.pj.wisdomlogistics.mvp.frame.ActivityPresenter;
import com.pj.wisdomlogistics.mvp.model.RepairModel;
import com.pj.wisdomlogistics.rx.FilterSubscriber;

import java.io.File;
import java.util.List;


public class RepairPresenter extends ActivityPresenter<RepairModel, RepairContract.View> implements RepairContract.Presenter {
    public static final String TAG = "RepairPresenter";

    @Override
    public void submitRepairApply(String userID, String questionIDs, String bespeakStartTime,
                                  String bespeakEndTime, String faultPlace, String faultDetail,
                                  String remark , List<File> mFiles , String place) {
        addSubscription(getModel().submitRepairApply(userID,
                questionIDs,
                bespeakStartTime,
                bespeakEndTime,
                faultPlace,
                faultDetail,
                remark ,
                mFiles,
                place), new FilterSubscriber<Double>() {
            @Override
            public void onNext(Double mInteger) {
                getView().onSuccess(mInteger);
            }

            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onError(errorCode , errorMsg);
            }

        });
    }

    @Override
    public void findQuestions() {
        addSubscription(getModel().findQuestions(), new FilterSubscriber<List<RepairQuestions>>() {
            @Override
            public void onNext(List<RepairQuestions> mList) {
                getView().onFindSuccess(mList);
            }

            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onError(errorCode , errorMsg);
            }

        });
    }
}
